import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import other from './router/other'
import Common from "@/components/Common"

createApp(App).use(store).use(router).mount('#app')

// 添加全局路由守卫
router.beforeEach(
    (to, from, next) => {
    //创建守卫规则集合(这里表示'/home'与'/news'路径是需要权限验证的)
    const nextRoute = ['/local'];
    // 使用isLogin来模拟是否登录
    let isLogin = false;
    console.log(nextRoute.indexOf(to.path));
    // 判断to.path(要跳转的路径)是否是需要权限验证的
    if (nextRoute.indexOf(to.path) >= 0) {
        if (!isLogin) {
            router.push({
                path: '/home/login'
            })
            //location.reload();
        }
    }
    next(); //必须要有
});